repo: change custom new method to std::path::Path-alike
authorFelix Krull <f_krull@gmx.de>
Sun, 7 Oct 2018 21:14:56 +0000 (23:14 +0200)
committerColin Walters <walters@verbum.org>
Fri, 6 May 2022 16:53:53 +0000 (12:53 -0400)
rust-bindings/rust/libostree/src/repo.rs
rust-bindings/rust/sample/src/main.rs

index 272c9002b147f8eae5714626b57cc6099562b346..4b887b2f6ab62f1cbf0b8bc2545cc9821d79ed56 100644 (file)
@@ -8,6 +8,7 @@ use glib::translate::*;
 use glib_ffi;
 use std::collections::HashSet;
 use std::ptr;
+use std::path::Path;
 use ObjectName;
 
 unsafe extern "C" fn read_variant_table(_key: glib_ffi::gpointer, value: glib_ffi::gpointer, hash_set: glib_ffi::gpointer) {
@@ -27,7 +28,7 @@ unsafe fn from_glib_container_variant_set(ptr: *mut glib_ffi::GHashTable) -> Has
 
 
 pub trait RepoExtManual {
-    fn new_for_str(path: &str) -> Repo;
+    fn new_for_path<P: AsRef<Path>>(path: P) -> Repo;
     fn traverse_commit<'a, P: Into<Option<&'a gio::Cancellable>>>(
         &self,
         commit_checksum: &str,
@@ -36,8 +37,8 @@ pub trait RepoExtManual {
 }
 
 impl<O: IsA<Repo> + IsA<glib::Object> + Clone + 'static> RepoExtManual for O {
-    fn new_for_str(path: &str) -> Repo {
-        Repo::new(&gio::File::new_for_path(path))
+    fn new_for_path<P: AsRef<Path>>(path: P) -> Repo {
+        Repo::new(&gio::File::new_for_path(path.as_ref()))
     }
 
     fn traverse_commit<'a, P: Into<Option<&'a gio::Cancellable>>>(
index a42d52ac584e72795bba810686b3ddd632646a0b..8e1ef5b8046de3977a4f559c1d0c6075f28acb69 100644 (file)
@@ -8,7 +8,7 @@ use gio::prelude::*;
 use libostree::prelude::*;
 
 fn main() {
-    let repo = libostree::Repo::new_for_str("../../../repo-bare");
+    let repo = libostree::Repo::new_for_path("../../../repo-bare");
 
     //let result = repo.create(libostree::RepoMode::Archive, Option::None);
     //result.expect("we did not expect this to fail :O");